import { Base } from "../../utils/base.js"

class Evaluate extends Base {
  constructor() {
    super();
  }

//提交评论信息
 submitEvaluate(evalData,callback) {
    var params = {
      url: 'product-comment/add',
      data: evalData,
      type: 'post',
      sCallback: function (data) {
        callback && callback(data);
      }
    }
    this.request(params);
  }

  //获取某个订单下的评论列表
  getEvaluateList(id,callback){
    
    var params = {
      url: 'order/getskus',
      data: { 'order_id':id},
      type: 'post',
      sCallback: function (data) {
        callback && callback(data);
      }
    }
    this.request(params);
  }

  //获取某个商品评论列表
  getEvalLists(param, page,callback) {
    var params = {
      url: 'product/comment?expand=member,replys&page=' + page,
      data: param,
      type: 'post',
      sCallback: function (data) {
        callback && callback(data);
      }
    }
    this.request(params);
  }

  toDate(number){
    var n = number * 1000;
    var date = new Date(n);
    var Y = date.getFullYear() + '-';
    var M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
    var D = date.getDate() < 10 ? '0' + date.getDate() : date.getDate();
    var h = ' '+(date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ':';
    var m = date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes();
   // var s = date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds();
    return (Y + M + D + h + m) 
  }

};

export { Evaluate };